// SetingColor.cpp : implementation file
//

#include "stdafx.h"
#include "yujinsrhost.h"
#include "SetingColor.h"
#include "MainFrm.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSetingColor dialog


CSetingColor::CSetingColor(CWnd* pParent /*=NULL*/)
	: CDialog(CSetingColor::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSetingColor)
	m_nSelectedColor = -1;
	m_bBlackBackground = FALSE;
	m_sYmin = _T("");
	m_sUmin = _T("");
	m_sVmin = _T("");
	m_sYmax = _T("");
	m_sUmax = _T("");
	m_sVmax = _T("");
	//}}AFX_DATA_INIT
}


void CSetingColor::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSetingColor)
	DDX_Control(pDX, IDC_YMIN_SCROLLBAR, m_Ymin_Scrollbar);
	DDX_Control(pDX, IDC_YMAX_SCROLLBAR, m_Ymax_Scrollbar);
	DDX_Control(pDX, IDC_UMIN_SCROLLBAR, m_Umin_Scrollbar);
	DDX_Control(pDX, IDC_UMAX_SCROLLBAR, m_Umax_Scrollbar);
	DDX_Control(pDX, IDC_VMIN_SCROLLBAR, m_Vmin_Scrollbar);
	DDX_Control(pDX, IDC_VMAX_SCROLLBAR, m_Vmax_Scrollbar);
	DDX_Radio(pDX, IDC_BALL_COLOR, m_nSelectedColor);
	DDX_Check(pDX, IDC_BLACK_BACKGROUND_CHECK, m_bBlackBackground);
	DDX_Text(pDX, IDC_YMIN_STATIC, m_sYmin);
	DDX_Text(pDX, IDC_UMIN_STATIC, m_sUmin);
	DDX_Text(pDX, IDC_VMIN_STATIC, m_sVmin);
	DDX_Text(pDX, IDC_YMAX_STATIC, m_sYmax);
	DDX_Text(pDX, IDC_UMAX_STATIC, m_sUmax);
	DDX_Text(pDX, IDC_VMAX_STATIC, m_sVmax);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSetingColor, CDialog)
	//{{AFX_MSG_MAP(CSetingColor)
	ON_WM_TIMER()
	ON_WM_HSCROLL()
	ON_BN_CLICKED(IDC_BALL_COLOR, OnBallColor)
	ON_BN_CLICKED(IDC_ID1_COLOR, OnId1Color)
	ON_BN_CLICKED(IDC_ID2_COLOR, OnId2Color)
	ON_BN_CLICKED(IDC_ID3_COLOR, OnId3Color)
	ON_BN_CLICKED(IDC_OPPONENT_COLOR, OnOpponentColor)
	ON_BN_CLICKED(IDC_TEAM_COLOR, OnTeamColor)
	ON_BN_CLICKED(IDC_BLACK_BACKGROUND_CHECK, OnBlackBackgroundCheck)
	ON_BN_CLICKED(IDC_IDCOLOR45, OnIdcolor45)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSetingColor message handlers

void CSetingColor::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default

		MdigGrab(((CMainFrame*)AfxGetMainWnd())->MilDigitizer,((CMainFrame*)AfxGetMainWnd())->MilImageBuffer);

		if(MbufInquire(((CMainFrame*)AfxGetMainWnd())->MilImageBuffer, M_HOST_ADDRESS, &((CMainFrame*)AfxGetMainWnd())->pView->m_pImage) == NULL) //Memory Address Setup 
			AfxMessageBox("ERROR!!");

		MdigGrabWait(((CMainFrame*)AfxGetMainWnd())->MilDigitizer,M_GRAB_END);
		((CMainFrame*)AfxGetMainWnd())->pView->ConvertYUVRGB(((CMainFrame*)AfxGetMainWnd())->pView->m_pImage);
		//MdigHalt(((CMainFrame*)AfxGetMainWnd())->MilDigitizer);

		int NumPixel;
		int yL,yH, u, v;
		unsigned long Data;

		int color[6]={0,0,0,0,0,0};

		color[0] = atoi((const char *)(m_sYmin));
		color[1] = atoi((const char *)(m_sYmax));
		color[2] = atoi((const char *)(m_sUmin));
		color[3] = atoi((const char *)(m_sUmax));
		color[4] = atoi((const char *)(m_sVmin));
		color[5] = atoi((const char *)(m_sVmax));
		
		

		HDC hdc = ::GetDC(((CMainFrame*)AfxGetMainWnd())->pView->m_hWnd);// Attach the device context.
		CDC NewDC;
		NewDC.Attach(hdc);
		BYTE *ptrBuf = ((CMainFrame*)AfxGetMainWnd())->pView->DisplayByteTypeImage; 
		
		NumPixel = 0;

		if(m_bBlackBackground) {
			for(int h = 0;h < HEIGHT;h++){
				for(int w = 0;w < WIDTH;w+=2){
					Data=((CMainFrame*)AfxGetMainWnd())->pView->TwoArrybuf[h][w];
					yL = (BYTE)((Data >>  0)	& 0x000000ff);
					u  = (BYTE)((Data >>  8)	& 0x000000ff);
					yH = (BYTE)((Data >> 16)	& 0x000000ff);
					v =	 (BYTE)((Data >> 24)	& 0x000000ff);
				
					if(	yL >= color[0] && yL <= color[1] && 
						u >= color[2] && u <= color[3] &&
						v >= color[4] && v <= color[5] ) 
					{
						Data = (((CMainFrame*)AfxGetMainWnd())->pView->DisplayGroundArray[h][w-1]);
						*(ptrBuf+2) = (BYTE)((Data   >>  16)	& 0x000000ff);
						*(ptrBuf+1) = (BYTE)((Data >>  8 )		& 0x000000ff);
						*(ptrBuf  ) = (BYTE)((Data >>  0 )		& 0x000000ff);
			
					} 
					else {
						*(ptrBuf)	= 0;
						*(ptrBuf+1) = 0;
						*(ptrBuf+2) = 0;
					}					
					ptrBuf +=4;
					if(	yL >= color[0] && yL <= color[1] && 
						u >= color[2] && u <= color[3] &&
						v >= color[4] && v <= color[5] ) 
					{
						Data = (((CMainFrame*)AfxGetMainWnd())->pView->DisplayGroundArray[h][w]);
						*(ptrBuf+2) = (BYTE)((Data   >>  16)		& 0x000000ff);
						*(ptrBuf+1) = (BYTE)((Data >>  8 )		& 0x000000ff);
						*(ptrBuf  ) = (BYTE)((Data >>  0 )		& 0x000000ff);
					} 
					else
					{
						*(ptrBuf)	= 0;
						*(ptrBuf+1) = 0;
						*(ptrBuf+2) = 0;				
					}
					ptrBuf +=4;
				}
			}
		}
		else {
				for(int h = 0;h < HEIGHT;h++){
				for(int w = 0;w < WIDTH;w+=2){
					Data=((CMainFrame*)AfxGetMainWnd())->pView->TwoArrybuf[h][w];
					yL = (BYTE)((Data >>  0)	& 0x000000ff);
					u  = (BYTE)((Data >>  8)	& 0x000000ff);
					yH = (BYTE)((Data >> 16)	& 0x000000ff);
					v =	 (BYTE)((Data >> 24)	& 0x000000ff);
				
					if(	yL >= color[0] && yL <= color[1] && 
						u >= color[2] && u <= color[3] &&
						v >= color[4] && v <= color[5] ) 
					{
						*(ptrBuf)	= 0;
						*(ptrBuf+1) = 255;
						*(ptrBuf+2) = 0;
			
					} 
					else {
						Data = (((CMainFrame*)AfxGetMainWnd())->pView->DisplayGroundArray[h][w-1]);
						*(ptrBuf+2) = (BYTE)((Data   >>  16)	& 0x000000ff);
						*(ptrBuf+1) = (BYTE)((Data >>  8 )		& 0x000000ff);
						*(ptrBuf  ) = (BYTE)((Data >>  0 )		& 0x000000ff);
					}					
					ptrBuf +=4;
					if(	yL >= color[0] && yL <= color[1] && 
						u >= color[2] && u <= color[3] &&
						v >= color[4] && v <= color[5] ) 
					{
						*(ptrBuf)	= 0;
						*(ptrBuf+1) = 255;
						*(ptrBuf+2) = 0;				

					} 
					else
					{
						Data = (((CMainFrame*)AfxGetMainWnd())->pView->DisplayGroundArray[h][w]);
						*(ptrBuf+2) = (BYTE)((Data   >>  16)		& 0x000000ff);
						*(ptrBuf+1) = (BYTE)((Data >>  8 )		& 0x000000ff);
						*(ptrBuf  ) = (BYTE)((Data >>  0 )		& 0x000000ff);

					}
					ptrBuf +=4;
				}
			}
		}
		CBitmap		bitmap; 
		CDC			dcMemory;
	
	    dcMemory.CreateCompatibleDC(&NewDC);
	
		bitmap.CreateCompatibleBitmap(&NewDC,640,480);
		bitmap.SetBitmapBits(640*480*4,((CMainFrame*)AfxGetMainWnd())->pView->DisplayByteTypeImage);
		dcMemory.SelectObject(bitmap);
		NewDC.BitBlt(0,0,640,480,&dcMemory,0,0,SRCCOPY);	
		NewDC.Detach();

		//MdigGrabContinuous(((CMainFrame*)AfxGetMainWnd())->MilDigitizer,((CMainFrame*)AfxGetMainWnd())->MilImageBuffer);
		//((CMainFrame*)AfxGetMainWnd())->pView->DisplayDD(((CMainFrame*)AfxGetMainWnd())->pView->m_pImage);
		::ReleaseDC(((CMainFrame*)AfxGetMainWnd())->pView->m_hWnd,hdc );
        // Delete created device context. 
		

		

	CDialog::OnTimer(nIDEvent);
}

BOOL CSetingColor::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	
	m_Ymin_Scrollbar.SetScrollRange(0,255);
	m_Ymax_Scrollbar.SetScrollRange(0,255);
	m_Umin_Scrollbar.SetScrollRange(0,255);
	m_Umax_Scrollbar.SetScrollRange(0,255);
	m_Vmin_Scrollbar.SetScrollRange(0,255);
	m_Vmax_Scrollbar.SetScrollRange(0,255);

	m_Ymin_Scrollbar.SetScrollPos(this->m_nYminInit); 
	m_Ymax_Scrollbar.SetScrollPos(this->m_nYmaxInit); 
	m_Umin_Scrollbar.SetScrollPos(this->m_nUminInit); 
	m_Umax_Scrollbar.SetScrollPos(this->m_nUmaxInit); 
	m_Vmin_Scrollbar.SetScrollPos(this->m_nVminInit); 
	m_Vmax_Scrollbar.SetScrollPos(this->m_nVmaxInit); 

	char sPos[25];
	itoa(m_Ymin_Scrollbar.GetScrollPos(),sPos,10);
	m_sYmin = sPos;
	itoa(m_Ymax_Scrollbar.GetScrollPos(),sPos,10);
	m_sYmax = sPos;
	itoa(m_Umin_Scrollbar.GetScrollPos(),sPos,10);
	m_sUmin = sPos;
	itoa(m_Umax_Scrollbar.GetScrollPos(),sPos,10);
	m_sUmax = sPos;
	itoa(m_Vmin_Scrollbar.GetScrollPos(),sPos,10);
	m_sVmin = sPos;
	itoa(m_Vmax_Scrollbar.GetScrollPos(),sPos,10);
	m_sVmax = sPos;
	m_bBlackBackground=TRUE;
	UpdateData(FALSE);
	
	SetTimer(1, 1000, NULL);
//	MdigGrabContinuous(((CMainFrame*)AfxGetMainWnd())->MilDigitizer,((CMainFrame*)AfxGetMainWnd())->MilImageBuffer);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CSetingColor::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	// TODO: Add your message handler code here and/or call default
		// TODO: Add your message handler code here and/or call default
	long nID, index;		
	int value=0;

	nID	= GetWindowLong(pScrollBar->m_hWnd, GWL_ID);		
	index = nID-IDC_YMIN_SCROLLBAR;
	switch(index){
	case 0:                                
   		value = atoi((const char *)m_sYmin);  	
		break;     
	case 1:                                
   		value = atoi((const char *)m_sYmax);	
		break;     
	case 2:                                
   		value = atoi((const char *)m_sUmin);  	  	
		break;     
	case 3:                                
   		value = atoi((const char *)m_sUmax);  	  	
		break;     
	case 4:                                
   		value = atoi((const char *)m_sVmin);  	
		break;     
	case 5:                                
   		value = atoi((const char *)m_sVmax);  	
		break;     
		
	}	

	switch(nSBCode){                         
	case SB_LINEDOWN:
		value += 1; 
		break;
	case SB_LINEUP:   
		value += -1;
		break;
	case SB_PAGEDOWN:                               
		value += 5;
		break;						
	case SB_PAGEUP:                                                                                         
		value += -5;
		break;						                                  
	case SB_BOTTOM:
		value = 0;
		break;
	case SB_TOP:     
		value = 255;
		break;
	case SB_THUMBTRACK:
	case SB_THUMBPOSITION:
		value = nPos;
		break;																				
	default:						          
		CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
		return;
	}
	
	if(value > 255)     
		value = 255;
	else if(value < 0)
		value = 0;
	pScrollBar->SetScrollPos(value); 
	SetDlgItemInt(nID, value, FALSE);		 	                   				

	char tmp[25];
	sprintf(tmp, "%d", value); 
	switch(index){
	case 0:                                
    	m_sYmin = tmp; 
    	break;
	case 1:                
		m_sYmax = tmp; 
    	break;
	case 2:                
		m_sUmin = tmp; 
    	break;
	case 3:                
		m_sUmax = tmp; 
    	break;
	case 4:                
		m_sVmin = tmp; 
    	break;
	case 5:                
		m_sVmax = tmp; 
    	break;
		
	}                 
	UpdateData(FALSE);
	
	CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}


void CSetingColor::OnBallColor() 
{
	UpdateData(TRUE);
	if(m_bChangeOrSet==true)
		return;

	m_Ymin_Scrollbar.SetScrollPos(this->ballcolor[0]); 
	m_Ymax_Scrollbar.SetScrollPos(this->ballcolor[1]); 
	m_Umin_Scrollbar.SetScrollPos(this->ballcolor[2]); 
	m_Umax_Scrollbar.SetScrollPos(this->ballcolor[3]); 
	m_Vmin_Scrollbar.SetScrollPos(this->ballcolor[4]); 
	m_Vmax_Scrollbar.SetScrollPos(this->ballcolor[5]); 

	char sPos[25];
	itoa(m_Ymin_Scrollbar.GetScrollPos(),sPos,10);
	m_sYmin = sPos;
	itoa(m_Ymax_Scrollbar.GetScrollPos(),sPos,10);
	m_sYmax = sPos;
	itoa(m_Umin_Scrollbar.GetScrollPos(),sPos,10);
	m_sUmin = sPos;
	itoa(m_Umax_Scrollbar.GetScrollPos(),sPos,10);
	m_sUmax = sPos;
	itoa(m_Vmin_Scrollbar.GetScrollPos(),sPos,10);
	m_sVmin = sPos;
	itoa(m_Vmax_Scrollbar.GetScrollPos(),sPos,10);
	m_sVmax = sPos;
	UpdateData(FALSE);
	// TODO: Add your control notification handler code here
	
}

void CSetingColor::OnId1Color() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	if(m_bChangeOrSet==true)
		return;
	 
	m_Ymin_Scrollbar.SetScrollPos(this->idcolor[0][0]); 
	m_Ymax_Scrollbar.SetScrollPos(this->idcolor[0][1]); 
	m_Umin_Scrollbar.SetScrollPos(this->idcolor[0][2]); 
	m_Umax_Scrollbar.SetScrollPos(this->idcolor[0][3]); 
	m_Vmin_Scrollbar.SetScrollPos(this->idcolor[0][4]); 
	m_Vmax_Scrollbar.SetScrollPos(this->idcolor[0][5]); 

	char sPos[25];
	itoa(m_Ymin_Scrollbar.GetScrollPos(),sPos,10);
	m_sYmin = sPos;
	itoa(m_Ymax_Scrollbar.GetScrollPos(),sPos,10);
	m_sYmax = sPos;
	itoa(m_Umin_Scrollbar.GetScrollPos(),sPos,10);
	m_sUmin = sPos;
	itoa(m_Umax_Scrollbar.GetScrollPos(),sPos,10);
	m_sUmax = sPos;
	itoa(m_Vmin_Scrollbar.GetScrollPos(),sPos,10);
	m_sVmin = sPos;
	itoa(m_Vmax_Scrollbar.GetScrollPos(),sPos,10);
	m_sVmax = sPos;
	UpdateData(FALSE);
}

void CSetingColor::OnId2Color() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	if(m_bChangeOrSet==true)
		return;
	 
	m_Ymin_Scrollbar.SetScrollPos(this->idcolor[1][0]); 
	m_Ymax_Scrollbar.SetScrollPos(this->idcolor[1][1]); 
	m_Umin_Scrollbar.SetScrollPos(this->idcolor[1][2]); 
	m_Umax_Scrollbar.SetScrollPos(this->idcolor[1][3]); 
	m_Vmin_Scrollbar.SetScrollPos(this->idcolor[1][4]); 
	m_Vmax_Scrollbar.SetScrollPos(this->idcolor[1][5]); 

	char sPos[25];
	itoa(m_Ymin_Scrollbar.GetScrollPos(),sPos,10);
	m_sYmin = sPos;
	itoa(m_Ymax_Scrollbar.GetScrollPos(),sPos,10);
	m_sYmax = sPos;
	itoa(m_Umin_Scrollbar.GetScrollPos(),sPos,10);
	m_sUmin = sPos;
	itoa(m_Umax_Scrollbar.GetScrollPos(),sPos,10);
	m_sUmax = sPos;
	itoa(m_Vmin_Scrollbar.GetScrollPos(),sPos,10);
	m_sVmin = sPos;
	itoa(m_Vmax_Scrollbar.GetScrollPos(),sPos,10);
	m_sVmax = sPos;
	UpdateData(FALSE);
}

void CSetingColor::OnId3Color() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	if(m_bChangeOrSet==true)
		return;
	 
	m_Ymin_Scrollbar.SetScrollPos(this->idcolor[2][0]); 
	m_Ymax_Scrollbar.SetScrollPos(this->idcolor[2][1]); 
	m_Umin_Scrollbar.SetScrollPos(this->idcolor[2][2]); 
	m_Umax_Scrollbar.SetScrollPos(this->idcolor[2][3]); 
	m_Vmin_Scrollbar.SetScrollPos(this->idcolor[2][4]); 
	m_Vmax_Scrollbar.SetScrollPos(this->idcolor[2][5]); 

	char sPos[25];
	itoa(m_Ymin_Scrollbar.GetScrollPos(),sPos,10);
	m_sYmin = sPos;
	itoa(m_Ymax_Scrollbar.GetScrollPos(),sPos,10);
	m_sYmax = sPos;
	itoa(m_Umin_Scrollbar.GetScrollPos(),sPos,10);
	m_sUmin = sPos;
	itoa(m_Umax_Scrollbar.GetScrollPos(),sPos,10);
	m_sUmax = sPos;
	itoa(m_Vmin_Scrollbar.GetScrollPos(),sPos,10);
	m_sVmin = sPos;
	itoa(m_Vmax_Scrollbar.GetScrollPos(),sPos,10);
	m_sVmax = sPos;
	UpdateData(FALSE);
}

void CSetingColor::OnOpponentColor() 
{
		UpdateData(TRUE);
	if(m_bChangeOrSet==true)
		return;

	m_Ymin_Scrollbar.SetScrollPos(this->opponentcolor[0]); 
	m_Ymax_Scrollbar.SetScrollPos(this->opponentcolor[1]); 
	m_Umin_Scrollbar.SetScrollPos(this->opponentcolor[2]); 
	m_Umax_Scrollbar.SetScrollPos(this->opponentcolor[3]); 
	m_Vmin_Scrollbar.SetScrollPos(this->opponentcolor[4]); 
	m_Vmax_Scrollbar.SetScrollPos(this->opponentcolor[5]); 

	char sPos[25];
	itoa(m_Ymin_Scrollbar.GetScrollPos(),sPos,10);
	m_sYmin = sPos;
	itoa(m_Ymax_Scrollbar.GetScrollPos(),sPos,10);
	m_sYmax = sPos;
	itoa(m_Umin_Scrollbar.GetScrollPos(),sPos,10);
	m_sUmin = sPos;
	itoa(m_Umax_Scrollbar.GetScrollPos(),sPos,10);
	m_sUmax = sPos;
	itoa(m_Vmin_Scrollbar.GetScrollPos(),sPos,10);
	m_sVmin = sPos;
	itoa(m_Vmax_Scrollbar.GetScrollPos(),sPos,10);
	m_sVmax = sPos;
	UpdateData(FALSE);
}

void CSetingColor::OnTeamColor() 
{
		UpdateData(TRUE);
	if(m_bChangeOrSet==true)
		return;

	m_Ymin_Scrollbar.SetScrollPos(this->teamcolor[0]); 
	m_Ymax_Scrollbar.SetScrollPos(this->teamcolor[1]); 
	m_Umin_Scrollbar.SetScrollPos(this->teamcolor[2]); 
	m_Umax_Scrollbar.SetScrollPos(this->teamcolor[3]); 
	m_Vmin_Scrollbar.SetScrollPos(this->teamcolor[4]); 
	m_Vmax_Scrollbar.SetScrollPos(this->teamcolor[5]); 

	char sPos[25];
	itoa(m_Ymin_Scrollbar.GetScrollPos(),sPos,10);
	m_sYmin = sPos;
	itoa(m_Ymax_Scrollbar.GetScrollPos(),sPos,10);
	m_sYmax = sPos;
	itoa(m_Umin_Scrollbar.GetScrollPos(),sPos,10);
	m_sUmin = sPos;
	itoa(m_Umax_Scrollbar.GetScrollPos(),sPos,10);
	m_sUmax = sPos;
	itoa(m_Vmin_Scrollbar.GetScrollPos(),sPos,10);
	m_sVmin = sPos;
	itoa(m_Vmax_Scrollbar.GetScrollPos(),sPos,10);
	m_sVmax = sPos;
	UpdateData(FALSE);
}

void CSetingColor::OnBlackBackgroundCheck() 
{
	UpdateData(TRUE);
	if(m_bChangeOrSet==true)
		return;

	UpdateData(FALSE);
}

void CSetingColor::OnIdcolor45() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	if(m_bChangeOrSet==true)
		return;
	 
	m_Ymin_Scrollbar.SetScrollPos(this->idcolor[3][0]); 
	m_Ymax_Scrollbar.SetScrollPos(this->idcolor[3][1]); 
	m_Umin_Scrollbar.SetScrollPos(this->idcolor[3][2]); 
	m_Umax_Scrollbar.SetScrollPos(this->idcolor[3][3]); 
	m_Vmin_Scrollbar.SetScrollPos(this->idcolor[3][4]); 
	m_Vmax_Scrollbar.SetScrollPos(this->idcolor[3][5]); 

	char sPos[25];
	itoa(m_Ymin_Scrollbar.GetScrollPos(),sPos,10);
	m_sYmin = sPos;
	itoa(m_Ymax_Scrollbar.GetScrollPos(),sPos,10);
	m_sYmax = sPos;
	itoa(m_Umin_Scrollbar.GetScrollPos(),sPos,10);
	m_sUmin = sPos;
	itoa(m_Umax_Scrollbar.GetScrollPos(),sPos,10);
	m_sUmax = sPos;
	itoa(m_Vmin_Scrollbar.GetScrollPos(),sPos,10);
	m_sVmin = sPos;
	itoa(m_Vmax_Scrollbar.GetScrollPos(),sPos,10);
	m_sVmax = sPos;
	UpdateData(FALSE);
}
